import React, {Component} from 'react';
import {
    StyleSheet,
    View,
    Text,
    TouchableHighlight

} from 'react-native';
import  SecondPageComponent from  "./SecondPageComponent"

export  default  class FirstPage extends  Component{
    constructor(props){
        super(props);
        this.state={
            title:"title呵呵呵"
        }
    }
     clickJump(){
       const {navigator}=this.props;
         let that = this;
       if(navigator){
           navigator.push({
               name:"SecondPageComponent",
               component:SecondPageComponent,
               params:{
                   title:this.state.title,
                   id:1234,
                   getUser:function (user) {
                       that.setState({
                           user:user
                       })
                   }
               }
           })
       }
     }
     render(){
         return(
             <View style={styles.container}>
                 <Text>我是第一个界面</Text>
                 <TouchableHighlight
                  underlayColor="rgb(181,136,254)"
                  activeOpacity={0.5}
                  style={{ borderRadius: 8,padding: 8,marginTop:5,backgroundColor:"#0588fe"}}
                  onPress={this.clickJump.bind(this)}
                   >
                     <Text>点击进入第二个界面</Text>
                 </TouchableHighlight>
                 <Text>第二个界面返回:{this.state.user}</Text>
             </View>
         )
     }
}

const  styles=StyleSheet.create({
    container:{
        flex:1,
        backgroundColor:"#ffffff",
        justifyContent:"center",
        alignItems: 'center',
    }
})